<!-- 编辑会员架构 -->
<template>
  <a-modal v-model="visible" title="编辑会员架构">
    <a-form-model :model="form" ref="ruleForm" :rules="rules" :label-col="labelCol" :wrapper-col="wrapperCol">
      <a-form-model-item label="组织名称" prop="name">
        <a-input v-model="form.name" />
      </a-form-model-item>
      <a-form-model-item label="入会类型" prop="memberTypeList">
        <a-checkbox-group v-model="form.memberTypeList">
          <a-checkbox value="2"> 开启个人入会 </a-checkbox>
          <a-checkbox value="1"> 开启单位入会 </a-checkbox>
        </a-checkbox-group>
      </a-form-model-item>
      <div>
        <a-icon type="info-circle" />
        <span class="_ml-5"
          >个人入会是以个人身份加入组织，单位入会是指以公司的名义加入组织，不同的身份入会需填写的表单不同。</span
        >
      </div>
    </a-form-model>
    <template slot="footer">
      <a-button @click="visible = false">取消</a-button>
      <a-button type="primary" @click="handleSubmit">保存</a-button>
    </template>
  </a-modal>
</template>

<script>
import { OrganizationEdit } from '@/api/member/memberConfig'
export default {
  components: {},
  data() {
    return {
      visible: false,
      labelCol: { span: 4 },
      wrapperCol: { span: 14 },
      form: {
        id: undefined,
        name: undefined,
        memberTypeList: [],
      },
      rules: {
        name: [{ required: true, message: '请输入组织名称', trigger: 'change' }],
        memberTypeList: [{ required: true, message: '请选择入会类型', trigger: 'change' }],
      },
    }
  },
  computed: {},
  watch: {},
  methods: {
    openModel(row) {
      console.log('row---->', row)
      Object.keys(this.form).forEach((k) => {
        this.form[k] = row[k]
      })
      this.visible = true
    },
    handleSubmit() {
      this.$refs.ruleForm.validate(async (err) => {
        if (err) {
          await OrganizationEdit({ ...this.form })
          this.visible = false
          this.$message.success('保存成功')
          this.$emit('success')
        }
      })
    },
  },
  created() {},
  mounted() {},
}
</script>
<style scoped>
</style>